package com.bdqn.Di1Zhan;

import com.bdqn.Di1Zhan.entity.Person;

import java.lang.reflect.Modifier;

public class GetClassInfo {
    /**
     * @param args
     */
    public static void main(String[] args){
        Class clz = Person.class;
        String fullName = clz.getSimpleName();
        String simpleName = clz.getSimpleName();
        System.out.println("一下是"+fullName+"类的基本信息");
        System.out.println("-----------------------");

        Class superClass = clz.getSuperclass();
        System.out.println(simpleName+"类的超类是："+superClass.getName());
        System.out.println("----------------------------");

        Class[] interfaces = clz.getInterfaces();
        System.out.println(simpleName+"类所在的接口：");
        for (Class c:interfaces) {
            System.out.print("\t"+c.getName());
        }

        System.out.println("------------------------------");

        int modifier = clz.getModifiers();
        System.out.println(simpleName+"类的修饰符：");
        if ((modifier & Modifier.PUBLIC) == Modifier.PUBLIC)
            System.out.println("\t访问修饰符是：public");
        else
            System.out.println("\t访问修饰符是：default(package)");
        if ((modifier & Modifier.FINAL) == Modifier.FINAL)
            System.out.println("\t这是个类是final的");
        if ((modifier & Modifier.ABSTRACT) == Modifier.ABSTRACT)
            System.out.println("\t这是一个抽象类");
        if ((modifier & Modifier.INTERFACE) == Modifier.INTERFACE)
            System.out.println("\t这是一个接口");
        System.out.println("-----------------------------------");
    }
}
